﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace DataLayer.Dao.Sql
{
    public class DaoException : Exception
    {
        Boolean _isDeadLockFound = false;
        Boolean _isTimedOut = false;

        public DaoException() : base() { }

        public DaoException(String arg0) : base(arg0) { }

        public DaoException(String arg0, Exception arg1)
            : base(arg0, arg1)
        {
            if (arg1.GetType() == typeof(SqlException))
            {
                SqlException test = (SqlException)arg1;

                if (test.State == Convert.ToByte(40001))
                {
                    _isDeadLockFound = true;
                }

                if (test.Number == -2)
                {
                    _isTimedOut = true;
                }
            }
        }


        public Boolean isDeadLockFound()
        {
            return _isDeadLockFound;
        }

        public Boolean isTimedOut()
        {
            return _isTimedOut;
        }
    }
}
